<template>
  <div class="examples-container">
    <header class="page-header">
      <h1>示例中心</h1>
      <p class="subtitle">精选实用代码示例，帮助你快速掌握关键技术点</p>
    </header>

    <!-- 搜索和筛选区 -->
    <div class="search-filter">
      <div class="search-box">
        <input type="text" placeholder="搜索示例...">
      </div>
      <div class="filter-tags">
        <span class="tag active">全部</span>
        <span class="tag">后端</span>
        <span class="tag">前端</span>
        <span class="tag">数据库</span>
        <span class="tag">DevOps</span>
      </div>
    </div>

    <!-- 示例列表 -->
    <div class="examples-grid">
      <div class="example-card">
        <div class="example-header">
          <h3>JWT 认证实现</h3>
          <span class="difficulty beginner">入门</span>
        </div>
        <p class="description">完整演示 JWT token 的生成、验证和刷新流程</p>
        <div class="tech-tags">
          <span class="tech-tag">Node.js</span>
          <span class="tech-tag">Express</span>
          <span class="tech-tag">JWT</span>
        </div>
        <div class="actions">
          <button class="btn-primary">在线运行</button>
          <button class="btn-secondary">查看源码</button>
        </div>
      </div>

      <div class="example-card">
        <div class="example-header">
          <h3>Redis 分布式锁</h3>
          <span class="difficulty advanced">进阶</span>
        </div>
        <p class="description">使用 Redis 实现分布式锁，包含重入和超时处理</p>
        <div class="tech-tags">
          <span class="tech-tag">Java</span>
          <span class="tech-tag">Redis</span>
          <span class="tech-tag">Spring Boot</span>
        </div>
        <div class="actions">
          <button class="btn-primary">在线运行</button>
          <button class="btn-secondary">查看源码</button>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.examples-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
}

.page-header {
  text-align: center;
  margin-bottom: 3rem;
}

.page-header h1 {
  font-size: 2rem;
  color: var(--gray-900);
  margin-bottom: 1rem;
}

.subtitle {
  color: var(--gray-600);
}

.search-filter {
  margin-bottom: 2rem;
}

.search-box {
  margin-bottom: 1rem;
}

.search-box input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 1rem;
}

.filter-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  background: var(--gray-100);
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.2s;
}

.tag.active {
  background: var(--primary-600);
  color: white;
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.example-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 1.5rem;
  transition: all 0.2s;
}

.example-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.example-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.example-header h3 {
  font-size: 1.1rem;
  color: var(--gray-900);
}

.difficulty {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.875rem;
}

.beginner {
  background: var(--primary-50);
  color: var(--primary-700);
}

.advanced {
  background: #fff0f0;
  color: #dc2626;
}

.description {
  color: var(--gray-600);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.tech-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.tech-tag {
  padding: 0.25rem 0.5rem;
  background: var(--gray-100);
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--gray-700);
}

.actions {
  display: flex;
  gap: 0.75rem;
}

.actions button {
  flex: 1;
  padding: 0.5rem;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary-600);
  color: white;
  border: none;
}

.btn-primary:hover {
  background: var(--primary-700);
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}

.btn-secondary:hover {
  background: var(--gray-200);
}

@media (max-width: 768px) {
  .examples-container {
    padding: 1rem;
  }
  
  .examples-grid {
    grid-template-columns: 1fr;
  }
}
</style> 